package pta;/**
 * @author： li
 * @date： 2022-04-01 20:24
 * @version 1.0
 */

import java.io.*;
import java.util.*;
public class 点赞2 {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Map<Integer,Integer> map = new HashMap<>();
        map.put(0,0);
        int n=Integer.parseInt(in.readLine());
        while(n>0){
            String[] x=in.readLine().split(" ");
            int m =Integer.parseInt(x[0]);
            for(int i=1;i<=m;i++){
                int y=Integer.parseInt(x[i]);
                if(map.containsKey(y)){
                    int count=map.get(y)+1;
                    map.put(y,count);
                }else
                    map.put(y,1);
            }
            n--;
        }
        //Arraylist 包 map 对map排序
        List<Map.Entry<Integer,Integer>> list = new ArrayList<>(map.entrySet());
        Collections.sort(list,new Comparator<Map.Entry<Integer, Integer>>() {
            @Override
            public int compare(Map.Entry<Integer, Integer> o1, Map.Entry<Integer, Integer> o2) {
                return o1.getValue() - o2.getValue();
            }
        });
        int len =list.size();
        if(list.get(len-1).getValue()==list.get(len-2).getValue()) {
            if(list.get(len-1).getKey()>list.get(len-2).getKey())
                System.out.println(list.get(len-1).getKey()+" "+list.get(len-1).getValue());
            else
                System.out.println(list.get(len-2).getKey()+" "+list.get(len-2).getValue());

        }else {
            System.out.println(list.get(len-1).getKey()+" "+list.get(len-1).getValue());
        }
    }
}